<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台管理系统</title>
  <link rel="stylesheet" href="{{static_url('layui/css/layui.css')}}">
  <link rel="stylesheet" href="{{static_url('css/global.css')}}">
  <link rel="stylesheet" href="{{static_url('icheck/minimal/red.css')}}">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
 {% include 'temp_nav.html' %}
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <fieldset class="layui-elem-field">
            <legend>用户管理 - 用户列表</legend>
            <div class="layui-field-box">
              <form class="layui-form" action="">
                <div class="layui-form-item" style="text-align:center;">
                  <div class="layui-inline">
                    <div class="layui-input-inline">
                      <input autocomplete="off" class="layui-input" placeholder="请输入名称" type="text" name="name" value="">
                    </div>
                  </div>
                  <div class="layui-inline" style="text-align:left;">
                    <div class="layui-input-inline">
                      <button class="layui-btn"><i class="layui-icon">&#xe615;</i>查询</button>
                    </div>
                  </div>
                </div>
              </form>
              <hr>
              <!-- <div class="layui-btn-group">
                  <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog" dw-url="userAdd.html" dw-title="新增用户" dw-width="100%" dw-height="100%">
                      <i class="layui-icon">&#xe654;</i>新增
                  </button>
                  <button class="layui-btn layui-btn-xs layui-btn-danger dw-batch-delete" dw-url="./delete.json">
                      <i class="layui-icon">&#xe640;</i>删除
                  </button>
                  <button class="layui-btn layui-btn-xs dw-refresh">
                      <i class="layui-icon">&#x1002;</i>刷新
                  </button>
              </div> -->
              <hr>
              <table class="layui-table">
                  <colgroup>
                      <col width="150">
                      <col width="150">
                      <col width="200">
                      <col>
                      <col>
                  </colgroup>
                  <thead>
                      <tr>
                     <!--  <th class="selectAll"><input type="checkbox"></th> -->
                      <th>昵称</th>
                      <th>邮箱</th>
                      <th>地址</th>
                      <th>手机号</th>
                      <th style="text-align:center;">操作</th>
                      </tr> 
                  </thead>
                  <tbody>
                     {% for adminView in result %}
                      <tr>
<!--                       <td><input type="checkbox" name="user_id" value="{{adminView['user_name']}}"></td>
 -->                         <td>{{adminView['user_name']}}</td>
                         <td>{{adminView['user_email']}}</td>
                         <td>{{adminView['user_address']}}</td>
                          <td>{{adminView['user_phone']}}</td>
                      <td class="text-center">
                        <div class="layui-btn-group">
                         <!--  <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog" dw-url="create.html?id=1" dw-title="编辑用户">
                            <i class="layui-icon">&#xe642;</i>编辑
                          </button> -->
                          <button class="layui-btn layui-btn-xs layui-btn-danger dw-deleteuser" dw-url="#" dw-title="小明" user_id="{{adminView['user_id']}}">
                            <i class="layui-icon">&#xe640;</i>禁用
                          </button>
                        </div>
                      </td>
                      </tr>
                      {% end %}
                  </tbody>
              </table>
            </div>
        </fieldset>
    </div>
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>
<script type="text/javascript" src="{{static_url('javascript/jquery.min.js')}}"></script>
<script type="text/javascript" src="{{static_url('layui/layui.js')}}"></script>
<script type="text/javascript" src="{{static_url('icheck/icheck.js')}}"></script>
<script type="text/javascript" src="{{static_url('javascript/dw.js')}}"></script>
<script type="text/javascript">
    $(function () {
        // 处理搜索按钮，根据标题进行模糊搜索
        $('.dw-deleteuser').click(function () {
            // 获取搜索框的内容
            var user_id = $(this).attr('user_id');

            $.ajax({
                type: 'POST',
                url: '/admin/userdel',
                data: {'user_id': user_id},
                dataType: 'json',
                success:function (data) {
                    if(data.result == 'ok'){
                        alert('禁用成功');
                        location.reload()
                    }else{
                        alert('禁用失败');
                    }
                    window.location.href=window.location.href;
                },
                error:function (jqXHR) {
                    alert('网络中断，请稍后再试');
                }
            });
        });
    });
</script>
</body>
</html>